package com.mask.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

/**
 * 日期格式转换
 * @author hx
 * @date 2021/10/15 5:40 下午
 */

public class DateFormatUtils {
    private static final Logger logger = LoggerFactory.getLogger(DateFormatUtils.class);

    /**
     * 字符串转date
     * @param source string
     * @return date
     */
    public static Date stringFormatDate(String source){
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        Date date = null;
        try {
            date = format.parse(source);
            return date;
        } catch (ParseException e) {
            logger.warn("字符串[{}]转日期失败",source);
            e.printStackTrace();
        }
        return date;
    }
}
